package com.example.mybaties.testone.aop.advisor;

import com.example.mybaties.testone.aop.common.WaiterServiceImpl;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;

import java.lang.reflect.Method;

/**
 * StaticMethodMatcherPointcutAdvisor默认情况下会匹配所有类
 */
public class GreetingAdvisor extends StaticMethodMatcherPointcutAdvisor {

    @Override
    public boolean matches(Method method, Class<?> targetClass) {
        if (method.getName().equals("greet")) {
            return true;
        }
        return false;
    }

    @Override
    public ClassFilter getClassFilter() {
        return new ClassFilter() {
            @Override
            public boolean matches(Class<?> clazz) {
                return WaiterServiceImpl.class.equals(clazz);
            }
        };
    }
}
